(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof this!=="undefined"){t=this}else if(typeof self!=="undefined"){t=self}else if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}t.videojsPlaylist=e()}})(function(){var e,t,i;return function n(e,t,i){function a(r,o){if(!t[r]){if(!e[r]){var d=typeof require=="function"&&require;if(!o&&d)return d(r,!0);if(l)return l(r,!0);var s=new Error("Cannot find module '"+r+"'");throw s.code="MODULE_NOT_FOUND",s}var f=t[r]={exports:{}};e[r][0].call(f.exports,function(t){var i=e[r][1][t];return a(i?i:t)},f,f.exports,n,e,t,i)}return t[r].exports}var l=typeof require=="function"&&require;for(var r=0;r<i.length;r++)a(i[r]);return a}({1:[function(e,t,i){(function(e){"use strict";Object.defineProperty(i,"__esModule",{value:true});function n(e){return e&&e.__esModule?e:{"default":e}}var a=typeof window!=="undefined"?window["videojs"]:typeof e!=="undefined"?e["videojs"]:null;var l=n(a);var r={thumbnailSize:190,playlistItems:3,hideIcons:false,upNext:true,hideSidebar:false,mobile:false};var o=undefined;var d=false;var s=[];var f=[];var u=[];var p=[];var v=null;var c=function N(e,t,i,n){var a=document.createElement("li");var l=document.createElement("div");l.className="vjs-playlist-video-title";l.setAttribute("data-index",t);if(t==0){if(r.upNext){var o=document.createElement("div");o.className="vjs-playlist-video-upnext";o.innerText="UP Next";l.appendChild(o)}}if(i){var d=document.createElement("div");d.innerText=i;d.setAttribute("data-index",t);l.appendChild(d);a.appendChild(l)}if(n)a.setAttribute("style","background-image: url('"+n+"');");a.setAttribute("data-index",t);a.onclick=function(t){var i=parseInt(t.target.getAttribute("data-index"));j(e,i,true)};return a};var m=function C(e,t){f[e.id_]=t.videos;s[e.id_]=0;d=t.playlist.mobile;if(t.playlist&&t.playlist.thumbnailSize){r.thumbnailSize=t.playlist.thumbnailSize.toString().replace("px","")}if(t.playlist&&t.playlist.items){r.playlistItems=t.playlist.items}if(t.playlist&&t.playlist.hideIcons){r.hideIcons=t.playlist.hideIcons}if(t.playlist&&t.playlist.hideSidebar){r.hideSidebar=t.playlist.hideSidebar}y(e,t);x(e)};var y=function B(e,t){v=document.createElement("ul");v.className="vjs-playlist-items";if(!r.hideSidebar){e.el().appendChild(v)}p[e.id_]=v;if(f[e.id_].length>0){f[e.id_].map(function(t,i){p[e.id_].appendChild(c(e.id_,i,t.title,t.thumbnail))});j(e.id_,0,false)}if(!r.hideIcons){var i=document.createElement("button");i.className="vjs-button-prev";i.onclick=g;e.controlBar.el().insertBefore(i,e.controlBar.playToggle.el());var n=document.createElement("button");n.className="vjs-button-next";n.onclick=b;e.controlBar.el().insertBefore(n,e.controlBar.volumeMenuButton.el())}e.on("ended",h);e.addClass("vjs-playlist")};var h=function I(){w()};var b=function S(e){var t=e.target.parentNode.parentNode.id;w(t)};var g=function A(e){var t=e.target.parentNode.parentNode.id;_(t)};var x=function z(e){var t=function i(e){var t=r.thumbnailSize;var i=e.el().id;var n=e.el().offsetWidth;var a=e.el().offsetHeight;var l=Math.floor((a-10)/r.playlistItems)-10;var o=e.$(".vjs-tech");var d=n-t;if(d>=0){var s=i+"_styles";var f=document.getElementById(s);if(!f)f=document.createElement("style");var u=" #"+i+".vjs-playlist .vjs-poster { width: "+d+"px !important; }"+" #"+i+".vjs-playlist .vjs-playlist-items { width: "+t+"px !important; }"+" #"+i+".vjs-playlist .vjs-playlist-items li { height: "+l+"px !important; }"+" #"+i+".vjs-playlist .vjs-modal-dialog { width: "+d+"px !important; } "+" #"+i+".vjs-playlist .vjs-control-bar, #"+i+".vjs-playlist .vjs-tech { width: "+d+"px !important; } "+" #"+i+".vjs-playlist .vjs-big-play-button, #"+i+".vjs-playlist .vjs-loading-spinner { left: "+Math.round(d/2)+"px !important; } "+" #"+i+" .vimeoFrame { width: "+d+"px !important; } "+" #"+i+" .vimeoFrame.vimeoHidden { padding-bottom: 0 !important; } ";f.setAttribute("id",s);f.setAttribute("type","text/css");document.getElementsByTagName("head")[0].appendChild(f);if(f.firstChild){f.firstChild.textContent=u}else{f.appendChild(document.createTextNode(u))}}};if(!r.hideSidebar){e.on("fullscreenchange",function(){t(this)});window.addEventListener("resize",function(i){t(e)});if(e){t(e)}}};var j=function L(e,t,i){if(!e){e=o.id_}s[e]=t;var n=u[e].el().querySelectorAll("ul.vjs-playlist-items li");for(var a=0;a<n.length;a++){if(a==t){n[a].classList.add("current")}else{n[a].classList.remove("current")}}try{if(!u[e].paused()){u[e].pause();u[e].error(null)}}catch(l){}var r={type:f[e][t].type,src:f[e][t].src};var p=e+"_wmv_player";if(r.type=="video/x-ms-wmv"){var v=document.getElementById(p);if(!v){v=document.createElement("div");v.setAttribute("id",p);v.setAttribute("class","vjs-tech");u[e].el().appendChild(v)}var c=u[e].wmvConfig;c.file=r.src;if(!!f[e][t].thumbnail)c.image=f[e][t].thumbnail;var m=new window.jeroenwijering.Player(v,"/bitrix/components/bitrix/player/wmvplayer/wmvplayer.xaml",u[e].wmvConfig)}else{var v=document.getElementById(p);if(!!v)v.parentNode.removeChild(v);var y=u[e].el().getElementsByClassName("vimeoFrame");for(var a=0;a<y.length;a++){y[a].classList.add("vimeoHidden")}if(r.type=="video/vimeo"){var h="vimeo_wrapper_"+e;if(!!document.getElementById(h))document.getElementById(h).classList.remove("vimeoHidden")}u[e].src(r);u[e].poster(f[e][t].thumbnail);if(!d&&(i||u[e].options_.autoplay)){try{u[e].play()}catch(l){}}}};var w=function M(e){if(!e){e=o.id_}if(s[e]<f[e].length-1){s[e]++}else{s[e]=0}j(e,s[e],true)};var _=function T(e){if(!e){e=o.id_}if(s[e]>0){s[e]--}else{s[e]=f[e].length-1}j(e,s[e],true)};var E=function q(e){var t=this;this.ready(function(){o=t;u[o.id_]=o;m(t,l["default"].mergeOptions(e,r))})};l["default"].plugin("playlist",E);i["default"]=E;t.exports=i["default"]}).call(this,typeof this!=="undefined"?this:typeof self!=="undefined"?self:typeof global!=="undefined"?global:typeof window!=="undefined"?window:{})},{}]},{},[1])(1)});
//# sourceMappingURL=videojs-playlist-dev.map.js